package nl.haemers.testrunners
{
	import flash.display.Sprite;
	import flash.events.Event;
	import com.bit101.components.CheckBox;
	import com.bit101.components.PushButton;
	import flash.events.MouseEvent;
	import flash.display.DisplayObjectContainer;
	import flash.geom.Rectangle;
	import nl.haemers.events.SpriteEvent;
	import nl.haemers.ui.buttons.MovieButton;
	import nl.haemers.ui.buttons.SpriteButton;
	
	import nl.haemers.base.BaseSprite;
	
	import nl.haemers.fake.TestButton;
	
	import nl.haemers.ui.behaviours.Draggable;
	/**
	 * @author Jonathan Haemers
	*/
	public class ButtonRunner extends BaseSprite
	{
		public var stateChecker			:CheckBox;
		public var button				:PushButton;
		public var movieButton			:TestButton;
		//public var spriteButton			:SpriteButton;
		
		public function ButtonRunner() 
		{
			super();
		}
		
		/** Public methods **/
		public function start() : void
		{
			
		}
		
		/** Getters & Setters **/
		
		/** Protected methods **/
		override protected function init(e:Event = null) : void
		{
			super.init(e);
			startup();
		}
		
		protected function startup() : void
		{
			createControls();
			createButtons();
		}
		public var dragButton:Draggable;
		protected function createButtons() : void
		{
			movieButton = new TestButton();
			movieButton = new Draggable(movieButton, true, new Rectangle(this.x, this.y, 200, 100)).target as TestButton;
			
			movieButton.x = 100;
			movieButton.y = 100;
			addChild(movieButton);	
		}
		
		protected function createControls() : void
		{
			stateChecker = new CheckBox(this, 200, 100, "Change state:", checkerHandler);
			button = new PushButton(this, 200, 150, "Destroy", buttonHandler);
		}
		
		protected function buttonHandler(e:Event) : void
		{
			dispatchEvent(new SpriteEvent( SpriteEvent.HIDE_COMPLETE));
		}
		
		protected function checkerHandler(e:Event) : void
		{
			movieButton.enabled = !movieButton.enabled;
		}
		
	}

}